package org.deadline.service.user;

import java.util.List;
import org.deadline.model.user.PersonSecurityQuestion;
import org.deadline.repository.user.PersonSecurityQuestionRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
@Transactional
public class PersonSecurityQuestionServiceImpl implements PersonSecurityQuestionService {

	@Autowired
    PersonSecurityQuestionRepository personSecurityQuestionRepository;

	public long countAllPersonSecurityQuestions() {
        return personSecurityQuestionRepository.count();
    }

	public void deletePersonSecurityQuestion(PersonSecurityQuestion personSecurityQuestion) {
        personSecurityQuestionRepository.delete(personSecurityQuestion);
    }

	public PersonSecurityQuestion findPersonSecurityQuestion(Long id) {
        return personSecurityQuestionRepository.findOne(id);
    }

	public List<PersonSecurityQuestion> findAllPersonSecurityQuestions() {
        return personSecurityQuestionRepository.findAll();
    }

	public List<PersonSecurityQuestion> findPersonSecurityQuestionEntries(int firstResult, int maxResults) {
        return personSecurityQuestionRepository.findAll(new org.springframework.data.domain.PageRequest(firstResult / maxResults, maxResults)).getContent();
    }

	public void savePersonSecurityQuestion(PersonSecurityQuestion personSecurityQuestion) {
        personSecurityQuestionRepository.save(personSecurityQuestion);
    }

	public PersonSecurityQuestion updatePersonSecurityQuestion(PersonSecurityQuestion personSecurityQuestion) {
        return personSecurityQuestionRepository.save(personSecurityQuestion);
    }
}
